package br.poli.ecomp.sma.massim.agent;

import jason.asSemantics.Agent;
import jason.asSemantics.Event;
import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
import jason.asSyntax.Trigger;

import java.util.List;
import java.util.Queue;

public class EcompAgent extends Agent {

	private Trigger t = Trigger.parseTrigger("+cow(_,_,_)");
	private Unifier un = new Unifier();
	private Trigger eos  = Trigger.parseTrigger("+end_of_simulation(_)");
	private boolean cleanCows = false;
	
	@Override
	public Event selectEvent(Queue<Event> events) {
		for (Event event : events) {
			if (un.unifies(t, event.getTrigger())) {
				return event;
			}
		}
		
		return super.selectEvent(events);
	}
	
	 public void cleanCows() {
	        cleanCows = true;
	    }
	    
	    @Override
	    public void buf(List<Literal> percepts) {
	        super.buf(percepts);
	/*        if (cleanCows) {
	            // remove old cows from the memory
	            int step = getTS().getUserAgArch().getCycleNumber();
	            if (step > 3) {
	                ((UniqueBelsBB)getTS().getAg().getBB()).remove_old_bels(Literal.parseLiteral("cow(x,x,x)"), "step", 6, step);
	                cleanCows = false;
	            }
	        }*/
	    }
	
}
